﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace ProgNetComponents.Design.Attributes
{
    [AttributeUsage(AttributeTargets.Property)]
    public class MonthDisplayNameAttribute : Attribute, IDynamicAttribute
    {
        private int month = -1;
        public MonthDisplayNameAttribute(int month)
        {
            if (month > 0 && month < 13)
                this.month = month;
        }
        #region IDynamicAttribute Members

        public Attribute GetRealAttribute(object target)
        {
            if (month > 0)
            {
                try
                {
                    return new DisplayNameAttribute(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month));
                }
                catch { }
            }
            return null;
        }

        #endregion
    }
}
